package com.boyaa.shells.tool 
{
	import com.boyaa.shells.GlobalConfig;
	import flash.utils.getTimer;
	/**
	 * ...
	 * @author zc
	 */
	public class SysTime
	{
		private static var _sysTime:Number = 0;     //从PHP获取的当前服务器时间
		private static var _csysTime:Number = 0;    //从C++获取的当前服务器时间
		private static var _delayTime:Number = 0;   //从初始化Flash Player到获取到PHP当前服务器时间中间的时间差
		private static var _cdelayTime:Number = 0;  //从初始化Flash Player到获取到C++当前服务器时间中间的时间差
		
		public function SysTime() 
		{
			
		}
		
		public static function getSysTime():Number 
		{ 
			var sTime:Number;
			//处理时差
			switch (GlobalConfig.lanVersion)
			{
				case 2://泰语服务器在香港(UTC+8) 比泰语当地时间快一个小时
				case 4://印尼服务器在新加坡(UTC+8) 比印尼当地时间快一个小时
					sTime = getTimer() / 1000 - 3600;
					break;
				case 6://(UTC+8) 比巴西当地时间快11个小时
					sTime = getTimer() / 1000 - 39600;
					break;
				default:
					sTime = getTimer() / 1000;
					break;
			}
			//当前系统时间 = 进游戏时获取PHP当前服务器时间 + 初始化Flash Player后经过的时间 - 从初始化Flash Player到获取到PHP当前服务器时间中间的时间差
			return _sysTime + sTime - _delayTime;
		}
		
		public static function getSysTimeEx():Number
		{
			return _sysTime + (getTimer() / 1000) - _delayTime;
		}
		
		public static function getCSysTime():Number
		{
			return _csysTime + (getTimer() / 1000) - _cdelayTime;
		}
		
		public static function setSysTime(value:Number):void 
		{
			_sysTime = value;
		}
		
		public static function setCSysTime(value:Number):void 
		{
			_csysTime = value;
		}
		
		public static function setDelayTime(value:Number):void 
		{
			_delayTime = value;
		}
		
		public static function setCDelayTime(value:Number):void 
		{
			_cdelayTime = value;
		}
	}

}